package com.example.springboot.mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
import com.example.springboot.pojo.Goods;
@Mapper
public interface GoodsMapper {
    @Delete("delete from goods where id=#{id}")
    void delete(Integer id);
    @Select("select * from goods")
    List<Goods> findAll();
    @Select("select * from goods where id=#{id}")
    Goods findById(Integer id);
    @Select("select * from goods where name like concat('%',#{name},'%')")
    List<Goods> findByName(String name);

    @Insert("INSERT INTO goods (name, photo, description, price, unit) " + "VALUES (#{name}, #{photo}, #{description}, #{price}, #{unit})")
    void create(Goods goods);

    @Update("update goods set name=#{name},photo=#{photo},description=#{description},price=#{price}," +
            "unit=#{unit},count=#{count} where id=#{id}")
    void update(Goods goods);

    //更新销量
    @Update("update goods set count=count+#{goodsnumber} where id=#{id}")
    void updateCount(Integer id,Integer goodsnumber);




}
